Methods
(static) makeArrayToObjectWith(valueToPair) → {function}
- Source:
- Since:
- 0.13.0
Return a function expecting an array and returning an object with keys and values defined by the provided function, which expects a value and returns a pair [key, value].
Example
> valueToPair = x => [`${x}${x}`, `${x}${x}${x}`];
> arrayToObject1 = makeArrayToObjectWith(valueToPair)
> arrayToObject1(['a', 'b', 1])
{aa: 'aaa', bb: 'bbb', 11: '111'}
>
> valueIndexToPair = (x, i) => [`${i}${i}`, `${x}${x}${x}`];
> arrayToObject2 = makeArrayToObjectWith(valueIndexToPair)
> arrayToObject2(['a', 'b', 1])
{'00': 'aaa', '11': 'bbb', '22': '111'}
Parameters:
Name | Type | Description |
---|---|---|
valueToPair |
function | (Any -> Array) Turns a value into a pair |
Returns:
- (Array -> Object)
- Type
- function